package org.hagen.mmia.yars.engine.corpora;

import java.util.ArrayList;
import java.util.StringTokenizer;

import org.tartarus.snowball.ext.EnglishStemmer;

public class Reader {

	final static boolean STEMMING = true;
	final static boolean STOPPING = true;
	
	private static EnglishStemmer english = new EnglishStemmer();		
	
	public static ArrayList<Abstract> abstracts = new ArrayList<Abstract>();

	
	public int getMaxDocumentID() {
		return 0;
	}
	
	public void readAbstract() {
		
	}
	
	public void readRelevance( ) {
		
	}
	
	public void readTopic( ) {
		
	}

	/*
	 * 
	 */
	protected static String doStemming( String line ) {
		
		String result = new String();
		
		// go through the line: stopping and stemming
		StringTokenizer st = new StringTokenizer( line );
		while( st.hasMoreTokens() ) {
			
			String token = st.nextToken();

			english.setCurrent( token );
			english.stem();
			result += " " + english.getCurrent();
		}

		return result;
	}

	/*
	 * 
	 */
	protected static String doStopping( String line ) {
		
		String result = new String();
		
		// go through the line: stopping and stemming
		StringTokenizer st = new StringTokenizer( line );
		while( st.hasMoreTokens() ) {
			
			String token = st.nextToken();

			if( ( !Stop.words.contains( token ) ) &&
					( token.matches( "[a-z]+" ) == true ) ) {
				result += " " + token;
			}
		}

		return result;
	}

}
